<?php
require_once __DIR__.'/BOFactory.class.php';
	
	class CategoryBORepository
	{   
		function getCategoryBOs()
		{	
			$categoryBOs=array();
			$categories = R::findAll( 'category' );
			foreach($categories as $k => $category)
			{
				array_push($categoryBOs,BOFactory::getCategoryBO($category->id));
			}			
			return $categoryBOs;
		}
		
		function getCategoryBO($id)
		{
			return BOFactory::getCategoryBO($id);
		}
		
		function getRootCategoryBOs()
		{	
			$categoryBOs=array();
			$categories = R::find( 'category','category_id is null' );
			foreach($categories as $k => $category)
			{
				array_push($categoryBOs,BOFactory::getCategoryBO($category->id));
			}			
			return $categoryBOs;
		}
		
		function getGrocerCatalog()
		{
			
			$categories = R::find( 'category','category_id is null' );
			foreach($categories as $k => $category)
			{
				if($category->seoid == 'grocer')
				{
				
				return BOFactory::getCategoryBO($category->id);
				}
			}	
		}
	}